<?php
declare(strict_types=1);

// +----------------------------------------------------------------------
// | 兔兔答题考试系统
// +----------------------------------------------------------------------
// | 感谢使用兔兔答题考试系统
// | 本系统经过商业授权，不能转售、开源或者以其他方式进行使用，只可在购买协议范围内容使用
// | 若发现未被版权协议，将追究相应的公司、团队、企业等
// | 访问官网：https://www.tutudati.com
// | 兔兔答题考试系统开发者版权所有 拥有最终解释权

namespace App\Http\Controllers\Audio;

use App\Http\Controllers\Controller;
use App\Http\Requests\Audio\AudioUidValidate;
use App\Library\Response;
use App\Logic\User\Service\Audio\AudioResourceService;
use Illuminate\Http\JsonResponse;

class AudioController extends Controller
{
    public function audioList(): JsonResponse
    {
        return Response::success((new AudioResourceService())->serviceSelect(request()->all()));
    }

    public function audioRelList(): JsonResponse
    {
        return Response::success((new AudioResourceService())->serviceRelSelect(request()->all()));
    }

    public function audioContent(AudioUidValidate $validate): JsonResponse
    {
        return Response::success((new AudioResourceService())->serviceFind(request()->all()));
    }

    public function audioCollection(AudioUidValidate $validate): JsonResponse
    {
        if ((new AudioResourceService())->serviceCollection((string)request()->post("uid"))) {
            return Response::success([], $this->successCode, "收藏成功");
        }
        return Response::error([], $this->errorCode, "收藏失败");
    }

    public function audioShare(AudioUidValidate $validate): JsonResponse
    {
        return Response::success([], $this->successCode, "分享成功");
    }
}
